<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <t:base type="jquery,easyui,tools,DatePicker,ckeditor"></t:base>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/blue.css"/>
    <link rel="stylesheet" href="${webRoot}/plug-in/lhgDialog/skins/default.css"/>
    <style>
        .viewimg{
            float: left;
            height: 100px;
            margin-right: 10px;
        }
        .uploadimg{
            float: left;
            min-width: 60px;
            padding: 0 10px;
            height: 30px;
            line-height: 30px;
            margin-top: 30px;
            background:#1964a0;
            color: #FFF;
            font-size:14px;
            text-align: center
        }
        .uploadimg:hover,.btnEditTag:hover{ color: #FFF;}
        .tags{
            display: inline-block;
            padding: 0 10px;
            line-height:28px;
            margin: 5px;
            border-radius: 3px;
            border:1px solid #DCDCDC;
        }
        .btnEditTag{
            display: inline-block;
            padding: 0 10px;
            margin: 5px;
            line-height:28px;
            background:#1964a0;
            color: #FFF;
            font-size:14px;
            text-align: center}
    </style>
    <script type="text/javascript" src="${webRoot}/plug-in/ajaxfileupload/ajaxfileupload.js"></script>

    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/ueditor1_4_3-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/QQgeo/geo.js"></script>
    <script type="text/javascript" charset="utf-8" src="${webRoot}/plug-in/My97DatePicker/WdatePicker.js"></script>

    <script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
    <script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.js"></script>
    <link rel="stylesheet" type="text/css" href="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
    <script type="text/javascript">
        //实例化编辑器
        //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
        var ue = UE.getEditor('editor');
        //加载完富文本后放入内容
        ue.ready( function( editor ) {
            var html = $("#brief").val();

            html = html.replace(/src="*.?upload/g, 'src="/xinxun_cloud/upload');

            ue.setContent(html);
        });
        //添加内容改变事件,编辑器内容改变后把内容赋值到隐藏表单
        ue.addListener( 'contentChange', function( editor ) {
            $("#brief").val(ue.getContent());
        } );

        /**
         * 提交之前触发
         */
        function f_goodsDesc(){
            //多文本框内容
            var brief = ue.getContent();
            //替换图片根路径
            brief = brief.replace(/src=\"\/mrh_cloud\/upload/g,'src="upload');
            $("#brief").val(brief);
        }

        //Ajax文件上传
        function f_file_upload(fileInputId, imgId, valueId) {
            var path = $("#" + fileInputId).val();

            var pos1 = path.lastIndexOf("\\");
            var pos2 = path.lastIndexOf(".");

            var fileName = path.substring(pos1 + 1, pos2);

            var result = path.substring(pos2 + 1, path.length);

            var imgs = ".bmp.jpg.dib.jpeg.png.jfif.jpe.tif.tiff.gif.BMP.JPG.DIB.JPEG.PNG.JFIF.JPE.TIF.TIFF.GIF";
            //文件类型 false为压缩包
            var boo = false;
            if (imgs.indexOf(result) > -1) {
                boo = true;
            } else {
                tip(" 只能上传后缀为 " + imgs + " 的文件！");
                $("#" + fileInputId).val("");
                return;
            }

            $.ajaxFileUpload({
                url: '${webRoot}/myFileUpload/uploadImageScale.do',
                secureuri: false,
                fileElementId: fileInputId,
                //dataType: 'json',
                success: function (data) {
                    var data2 = data.split(",");
                    var url = data2[0].replace(" ", "");
                    fileName = data2[1].replace(" ", "");

                    $("#" + imgId).attr("src", "${webRoot}/" + url);
                    $("#" + valueId).val(url);
                },
                error: function (data) {

                    console.log("error");
                    console.log(data);
                }
            });
        }
    </script>
</head>

<body scroll="no">
<t:formvalid formid="addformobj" dialog="true" usePlugin="password" layout="table"
             action="consultantController.do?saveorupdate" beforeSubmit="f_goodsDesc()">
    <%--callback="@Override noteSubmitCallback"--%>
    <input name="consultantId" type="hidden" value="${consultant.consultantId}">

    <div class="new_table_list">
        <table cellpadding="0" cellspacing="1" class="formtable" style="padding-left: 100px">
            <tbody>
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        姓名:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 200px;" name="aCustomerEntity.realname" value="${consultant.aCustomerEntity.realname}" datatype="*" maxlength="32">
                    <span class="Validform_checktip"></span>
                </td>
                <td align="left">
                    <label class="Validform_label">
                        性别:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect field="aCustomerEntity.sex" extendJson="{datatype:'*'}" typeGroupCode="sex"  defaultVal="${consultant.aCustomerEntity.sex}"  hasLabel="false"></t:dictSelect>
                    <span class="Validform_checktip"></span>
                </td>
            </tr>

            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        身份证号:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 200px;" name="aCustomerEntity.certNumber" value="${consultant.aCustomerEntity.certNumber}" datatype="*" maxlength="64">
                    <span class="Validform_checktip"></span>
                </td>
                <td align="left">
                    <label class="Validform_label">
                        所在地:
                    </label>
                </td>
                <td class="txt_left value">
                    <select id="s1" name="aCustomerEntity.province" style="width: 100px" datatype="*" nullmsg="请选择省"></select>
                    <select id="s2" name="aCustomerEntity.city" style="width: 100px" datatype="*" nullmsg="请选择市"></select>
                    <select id="s3" name="aCustomerEntity.area" style="width: 100px" datatype="*" nullmsg="请选择市、县级"></select>
                </td>
            </tr>

            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        出生日期:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt Wdate" style="width: 200px;" name="aCustomerEntity.birthday" id="birthday" datatype="*" maxlength="128" onclick="WdatePicker()">
                    <span class="Validform_checktip"></span>
                </td>
                <td align="left">
                    <label class="Validform_label">
                        学历:
                    </label>
                </td>
                <td class="txt_left value">
                    <t:dictSelect field="education" typeGroupCode="education"  defaultVal="${consultant.education}"   hasLabel="false"   extendJson="{datatype:'*';nullmsg:'请选择学历'}" ></t:dictSelect>
                    <span class="Validform_checktip"></span>
                </td>
            </tr>

            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        手机号码:
                    </label>
                </td>
                <td class="txt_left value">
                    <c:if test="${consultant.consultantId != null}">
                        ${consultant.aCustomerEntity.phone}
                    </c:if>
                    <c:if test="${consultant.consultantId == null}">
                        <input class="inputxt" style="width: 200px;" name="aCustomerEntity.phone" value="" datatype="*" maxlength="64" validType="a_customer,phone,customer_id">
                        <span class="Validform_checktip"></span>
                    </c:if>
                </td>

                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        排序:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 200px;" name="sort" value="${consultant.sort}" datatype="n1-10" maxlength="64" nullmsg="请输入排序">
                    <span class="Validform_checktip"></span>
                </td>
            </tr>

            <c:if test="${consultant.consultantId == null}">
            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        密码:
                    </label>
                </td>
                <td class="txt_left value">
                        <input class="inputxt" type="password" style="width: 200px;" id="pwd" name="aCustomerEntity.pwd" value="" datatype="*6-16" maxlength="16" >
                        <span class="Validform_checktip"></span>
                </td>

                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        确认密码:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt"  type="password"  style="width: 200px;" id="repeatPwd" name="repeatPwd" recheck="aCustomerEntity.pwd" name="repeatPwd" value="" datatype="*6-16" maxlength="16" nullmsg="请输入排序">
                    <span class="Validform_checktip"></span>
                </td>
            </tr>
            </c:if>

            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        头衔1:
                    </label>
                </td>
                <td class="txt_left value">
                        <input class="inputxt" style="width: 200px;" name="firstTitle" value="${consultant.firstTitle}" datatype="*" maxlength="32">
                        <span class="Validform_checktip"></span>
                </td>

                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        头衔2:
                    </label>
                </td>
                <td class="txt_left value">
                    <input class="inputxt" style="width: 200px;" name="secondTitle" value="${consultant.secondTitle}"  maxlength="32" >
                    <span class="Validform_checktip"></span>
                </td>
            </tr>

            <tr>
                <td align="left" style="width: 100px">
                    <label class="Validform_label">
                        头衔3:
                    </label>
                </td>
                <td class="txt_left value">
                        <input class="inputxt" style="width: 200px;" name="thirdTitle" value="${consultant.thirdTitle}"  maxlength="32">
                        <span class="Validform_checktip"></span>
                </td>

            </tr>

            <tr>
                <td align="left">
                    <label class="Validform_label">
                        身份证正面:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="certImageThumbImg"
                         src='${webRoot}/${consultant.aCustomerEntity.certImage}'  href="${webRoot}/${consultant.aCustomerEntity.certImage}"
                                                                                      class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="certImage"
                           onchange="f_file_upload('certImage','certImageThumbImg','certImageThumb')"/>
                    <input type="hidden" name="aCustomerEntity.certImage" id="certImageThumb"
                           value='${consultant.aCustomerEntity.certImage==null?"upload/none.jpg":consultant.aCustomerEntity.certImage}'/>
                </td>
                <td align="left">
                    <label class="Validform_label">
                        身份证反面:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="certImage2ThumbImg"
                         src='${webRoot}/${consultant.aCustomerEntity.certImage2}'  href="${webRoot}/${consultant.aCustomerEntity.certImage2}"
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="certImage2"
                           onchange="f_file_upload('certImage2','certImage2ThumbImg','certImage2Thumb')"/>
                    <input type="hidden" name="aCustomerEntity.certImage2" id="certImage2Thumb"
                           value='${consultant.aCustomerEntity.certImage2==null?"upload/none.jpg":consultant.aCustomerEntity.certImage2}'/>
                </td>
            </tr>

            <tr>
                <td align="left">
                    <label class="Validform_label">
                        头像:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="avatarThumbImg"
                         src='${webRoot}/${consultant.aCustomerEntity.avatar}' href="${webRoot}/${consultant.aCustomerEntity.avatar}"
                         class="viewimg" alt="预览" title="预览" width="100px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="avatar"
                           onchange="f_file_upload('avatar','avatarThumbImg','avatarThumb')"/>
                    <input type="hidden" name="aCustomerEntity.avatar" id="avatarThumb"
                           value='${consultant.aCustomerEntity.avatar==null?"upload/none.jpg":consultant.aCustomerEntity.avatar}'/>
                </td>
                <td align="left">
                    <label class="Validform_label">
                        执行资格证:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="certThumbImg"
                         src='${webRoot}/${consultant.cert}' href="${webRoot}/${consultant.cert}"
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="cert"
                           onchange="f_file_upload('cert','certThumbImg','certThumb')"/>
                    <input type="hidden" name="cert" id="certThumb"
                           value='${consultant.cert==null?"upload/none.jpg":consultant.cert}'/>
                </td>
            </tr>
            <tr>
                <td align="left" rowspan="3" valign="top">
                    <label class="Validform_label">
                        其他证件:
                    </label>
                </td>
                <td class="txt_left value">
                    <img id="auth1ThumbImg"
                         src='${webRoot}/${auth1==null?"upload/none.jpg":auth1}'  href="${webRoot}/${auth1==null?"upload/none.jpg":auth1}"
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="auth1"
                           onchange="f_file_upload('auth1','auth1ThumbImg','auth1Thumb')"/>
                    <input type="hidden" name="auth1" id="auth1Thumb"
                           value='${auth1}'/>
                </td>
                <td align="left">
                    <label class="Validform_label">

                    </label>
                </td>
                <td class="txt_left value">
                    <img id="auth2ThumbImg"
                         src='${webRoot}/${auth2==null?"upload/none.jpg":auth2}'  href="${webRoot}/${auth2==null?"upload/none.jpg":auth2}"
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="auth2"
                           onchange="f_file_upload('auth2','auth2ThumbImg','auth2Thumb')"/>
                    <input type="hidden" name="auth2" id="auth2Thumb"
                           value='${auth2}'/>
                </td>
            </tr>

            <tr>
                <td class="txt_left value">
                    <img id="auth3ThumbImg"
                         src='${webRoot}/${auth3==null?"upload/none.jpg":auth3}'   href="${webRoot}/${auth3==null?"upload/none.jpg":auth3}"
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="auth3"
                           onchange="f_file_upload('auth3','auth3ThumbImg','auth3Thumb')"/>
                    <input type="hidden" name="auth3" id="auth3Thumb"
                           value='${auth3}'/>
                </td>
                <td align="left">
                    <label class="Validform_label">

                    </label>
                </td>
                <td class="txt_left value">
                    <img id="auth4ThumbImg"
                         src='${webRoot}/${auth4==null?"upload/none.jpg":auth4}'   href="${webRoot}/${auth4==null?"upload/none.jpg":auth4}"
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="auth4"
                           onchange="f_file_upload('auth4','auth4ThumbImg','auth4Thumb')"/>
                    <input type="hidden" name="auth4" id="auth4Thumb"
                           value='${auth4}'/>
                </td>
            </tr>

            <tr>
                <td class="txt_left value">
                    <img id="auth5ThumbImg"
                         src='${webRoot}/${auth5==null?"upload/none.jpg":auth5}'   href="${webRoot}/${auth5==null?"upload/none.jpg":auth5}"
                         class="viewimg" alt="预览" title="预览" width="200px;" height="100px;">
                    <a href="javascript:;" class="uploadimg"
                       onclick="javascript:$(this).next().trigger('click')">上传图片</a>
                    <input type="file" style="display: none;" name="file"  id="auth5"
                           onchange="f_file_upload('auth5','auth5ThumbImg','auth5Thumb')"/>
                    <input type="hidden" name="auth5" id="auth5Thumb"
                           value='${auth5}'/>
                </td>
                <td colspan="3" align="left">
                    <label class="Validform_label">

                    </label>
                </td>
            </tr>

            <tr>
                <td align="left" valign="top">
                    <label class="Validform_label">
                        擅长领域:
                    </label>
                </td>
                <td colspan="3">
                    <div>
                        <span id="secondClassesTag">
                        <c:forEach items="${secondClassesTag}" var="t" varStatus="k">
                           <%-- <c:if test="${k.index !=0}">,</c:if>--%>
                           <span class="tags"> ${t.title}</span>
                        </c:forEach>
                        </span>
                        <a href="javascript:void(0);" onclick="add_second_classes()" class="btnEditTag">编辑标签</a>
                    </div>
                    <input type="hidden" id="secondClasses" name="secondClasses" value="${consultant.secondClasses}">
                </td>
            </tr>
            <tr>
                <td align="left" colspan="1">
                    <label class="Validform_label">
                        简介:
                    </label>
                </td>
                <td class="value" colspan="3">
                    <script id="editor" type="text/plain" style="width:800px; height:300px;"></script>
                    <textarea style="display: none;"  id="brief" name="brief" >${consultant.brief}</textarea>
                </td>
            </tr>
        </table>
    </div>
</t:formvalid>
<script>
    $(function(){
       var province = '${consultant.aCustomerEntity.province}';
       var city =  '${consultant.aCustomerEntity.city}';
       var area = '${consultant.aCustomerEntity.area}';
//        opt0=[province,city,area];;
        setup();
        initSelValue(province,city,area);
        $("#birthday").val(formatD());//生日
        bandImg();
    });

    function bandImg(){
        $("img.viewimg").fancybox({
            'overlayShow'	: false,
            'transitionIn'	: 'elastic',
            'transitionOut'	: 'elastic'
        });
    }

    /*
     *日期格式转换
     */
    function formatD(){
        var date =  '${consultant.aCustomerEntity.birthday}';
        if(date != ''){
            return formatDate(date);
        }else {
            return '';
        }
    }
    function formatDate(date) {
        var d = new Date(date),
            month = '' + (d.getMonth() + 1),
            day = '' + d.getDate(),
            year = d.getFullYear();

        if (month.length < 2) month = '0' + month;
        if (day.length < 2) day = '0' + day;

        return [year, month, day].join('-');
    }
    /**
     * 添加标签
     * @param second_classes
     */
    function add_second_classes(second_classes){
        var title="添加标签";
        var url="consultantController.do?secondClasses&ids="+second_classes+"&upiframename="+window.name;
        createwindow(title, url, 580, 530);
    }

    /**
     * 分类回调
     */
    function classes_callback(fname,ids,tags){
        $("iframe[name="+fname+"]", this.parent.parent.document)[0].contentWindow.f_closeWindow();
        $("#secondClasses").val(ids);
//        $("#secondClassesTag").html(tags);

        var tagarr = tags.split(",");
        var str="";
        for(var i=0;i<tagarr.length;i++){
            if(tagarr[i] !=''){
                str +="<span class=\"tags\"> "+tagarr[i]+"</span>";
            }
        }
        console.log(str);
        $("#secondClassesTag").html(str);
    }

</script>
</body>

</html>